import 'package:sp_util/sp_util.dart';

import 'ns_network_config.dart';

class NSNetWorkUtils {
  //单例
  factory NSNetWorkUtils() => _getInstance();

  static NSNetWorkUtils get instance => _getInstance();
  static NSNetWorkUtils? _instance;
  static late NSNetWorkConfig config;
  static bool isShowUpdateDialog = false;
  NSNetWorkUtils._internal();

  static NSNetWorkUtils _getInstance() {
    _instance ??= NSNetWorkUtils._internal();
    return _instance!;
  }

  initConfig(NSNetWorkConfig config) {
    NSNetWorkUtils.config = config;
  }

  static Future<bool> setAccessToken(String accessToken) async {
    return await SpUtil.putString('accessToken', accessToken) ?? false;
  }
  static String getAccessToken() {
    return SpUtil.getString('accessToken', defValue: "") ?? "";
  }
}